package com.gotop.common.base;

import com.gotop.common.utils.R;
import com.gotop.common.utils.auth.CemUser;
import com.gotop.common.utils.auth.SecureUtil;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;

/**
 * @program: cem
 * @description: 共用 Controller
 * @author: superfish
 * @create: 2020-12-22 13:53
 **/
public class BaseController {
    @Autowired
    private HttpServletRequest request;

    public BaseController() {
    }

    public HttpServletRequest getRequest() {
        return this.request;
    }

    public CemUser user() {
        return SecureUtil.getUser();
    }

    public <T> R<T> data(T data) {
        return R.data(data);
    }

    public <T> R<T> data(T data, String msg) {
        return R.data(data, msg);
    }

    public <T> R<T> data(T data, String msg, int code) {
        return R.data(code, data, msg);
    }

    public R success(String msg) {
        return R.success(msg);
    }

    public R fail(String msg) {
        return R.fail(msg);
    }

    public R status(boolean flag) {
        return R.status(flag);
    }

//    public BladeFile getFile(MultipartFile file) {
//        return BladeFileUtil.getFile(file);
//    }
//
//    public BladeFile getFile(MultipartFile file, String dir) {
//        return BladeFileUtil.getFile(file, dir);
//    }
//
//    public BladeFile getFile(MultipartFile file, String dir, String path, String virtualPath) {
//        return BladeFileUtil.getFile(file, dir, path, virtualPath);
//    }
//
//    public List<BladeFile> getFiles(List<MultipartFile> files) {
//        return BladeFileUtil.getFiles(files);
//    }
//
//    public List<BladeFile> getFiles(List<MultipartFile> files, String dir) {
//        return BladeFileUtil.getFiles(files, dir);
//    }
//
//    public List<BladeFile> getFiles(List<MultipartFile> files, String dir, String path, String virtualPath) {
//        return BladeFileUtil.getFiles(files, dir, path, virtualPath);
//    }
}